﻿using System;
using System.Windows.Forms;

namespace Ledict.Utility.Msg
{
    /// <summary>
    /// 显示消息提示对话框  v1.0
    /// </summary>
    public class MsgBox
    {

        /// <summary>
        /// 警告
        /// </summary>
        /// <param name="msg">信息</param>
        /// <returns></returns>
        public static DialogResult Warn(String msg)
        {
            return MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
        }

        /// <summary>
        /// 确认
        /// </summary>
        /// <param name="msg">信息</param>
        /// <returns></returns>
        public static DialogResult OK(String msg)
        {
            return MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
        }

        /// <summary>
        /// 错误
        /// </summary>
        /// <param name="msg">信息</param>
        /// <returns></returns>
        public static DialogResult Err(String msg)
        {
            return MessageBox.Show(msg, "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
        }

        /// <summary>
        /// 询问
        /// </summary>
        /// <param name="msg">信息</param>
        /// <returns></returns>
        public static DialogResult Ask(String msg)
        {
            return Ask(msg, null);
            //return MessageBox.Show(msg, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
        }

        /// <summary>
        /// 询问
        /// </summary>
        /// <param name="msg">信息</param>
        /// <param name="caption">标题</param>
        /// <returns></returns>
        public static DialogResult Ask(string msg, string caption)
        {
            return MessageBox.Show(msg, string.IsNullOrEmpty(caption) ? "提示" : caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
        }

        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="msg">信息</param>
        /// <returns></returns>
        public static DialogResult Save(String msg)
        {
            return MessageBox.Show(msg, "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
        }
    }
}
